package com.mm.controller;

import com.mm.util.AliyunOssUtil;
import com.mm.util.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.List;

/**
 * @ClassName FileUploadController
 * @Description TODO
 * @Author 任昊
 * @Date 2020/12/9 9:30
 */
@Api(tags = "用于文件上传的接口")
@RestController
public class FileUploadController {

    @ApiOperation(value = "文件上传",notes = "文件上传")
    @PostMapping("/uploadFile")
    public ResultUtil<Object> uploadFile(@RequestParam("files") MultipartFile files, HttpServletRequest request)throws IOException {
        String fileName = files.getOriginalFilename();
        List<String> url = AliyunOssUtil.OssFileUpload(request,fileName);
        return ResultUtil.success(url);
    }
}
